package com.globant.dashboard.webapp.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class HomeController {

	@RequestMapping(value = "home.do", method = RequestMethod.GET)
	public String Home(Model model, HttpSession session,
			HttpServletRequest request) {

		String pageForward;

		if (request.isUserInRole("ROLE_USER")) {
			pageForward = "redirect:/user/main.do";
		} else {
			pageForward = "redirect:/admin/main.do";
		}
		return pageForward;
	}


	@RequestMapping(value = "/logout.do", method = RequestMethod.GET)
	public String logout(Model model) {
		return "userLogin";

	}
}
